---
apiVersion: v1
kind: Service
metadata:
  name: {{ include "postgres-cluster.fullname" $ }}
  labels:
    application: spilo
    spilo-cluster: {{ include "postgres-cluster.fullname" $ }}
spec:
  type: {{ .Values.service.spilo.type }}
  ports:
    - name: {{ .Values.service.spilo.name }}
      port: {{ .Values.service.spilo.port }}
      protocol: {{ .Values.service.spilo.protocol }}
      targetPort: {{ .Values.service.spilo.targetPort }}
      {{- if .Values.service.spilo.nodePort }}
      nodePort: {{ .Values.service.spilo.nodePort }}
      {{- end }}

---
apiVersion: v1
kind: Service
metadata:
  name: {{ include "postgres-cluster.fullname" $ }}-config
  labels:
    application: spilo
    spilo-cluster: {{ include "postgres-cluster.fullname" $ }}
spec:
  clusterIP: {{ .Values.service.config.clusterIP }}
  ports:
    - name: {{ .Values.service.spilo.name }}
      port: {{ .Values.service.spilo.port }}
      protocol: {{ .Values.service.spilo.protocol }}
      targetPort: {{ .Values.service.spilo.targetPort }}